//
//  MyCoreHandle.h
//  RedManStock
//
//  Created by lanou3g on 15/8/5.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import <Foundation/Foundation.h>
@class MyCoreEntrust,MyCorePosition,SimpleStock;
@interface MyCoreHandle : NSObject
@property (nonatomic,strong) NSManagedObjectContext *mContext;


+(MyCoreHandle *)shareHandle;

- (NSManagedObjectContext *)mContext;

//position创建方法
- (MyCorePosition *)onePosition;

//entrust创建方法
- (MyCoreEntrust *)oneEntrust;

#pragma mark - MyPosition -
- (void)addMyPosition:(SimpleStock *)stock;

//增: 新成交的委托; 之前position的name，code以及nowPrice都知道
- (void)insertMyPosition:(SimpleStock *)stock;
//删
- (void)deleteMyPosition:(MyCorePosition *)position;


//改,每次请求好数据，或者委托成功后修改，主要计算成本价，持仓数量
- (void)updateMyPosition:(SimpleStock *)stock;

//查某个
- (MyCorePosition *)selectPositionWithCode:(NSString *)code;

//查全部
- (NSArray *)selectAllCorePosition;

#pragma mark - MyEntrust -

//增
- (void)addMyCoreEntrust:(SimpleStock *)stock;

//删
- (void)deleteMyEntrust:(NSString *)entrustDate;

//删除全部委托，用于15:00-17:00的清算
- (void)deleteAllMyEntrust;

//查一个，根据委托时间
- (MyCoreEntrust *)selectEntrustWithDate:(NSString *)entrustDate;

//查全部
-(NSArray *)selectAllEntrust;


@end
